package com.lm.bootclient.controller;

import com.lm.bootclient.service.ConsumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Value("${server.port}")
    String port;

    @Autowired
    ConsumeService consumeService;

    @RequestMapping("/hello")
    public String getHello(){
        return "hello Spring Cloud,server.port:" + port;
    }

    @RequestMapping("/reqservice")
    public String requertService(){
        return consumeService.requestServiceProvide();
    }

    @RequestMapping("/reqserviceHello")
    public String requertServiceHello(@RequestParam String name){
        return consumeService.requestServiceProvideHello(name);
    }

    public static void main(String[] args) {
        Person person = new Son();
        Person person2 = new Son2();
        System.out.println(((Son) person).get());
        System.out.println(person.check(1));
        System.out.println(person.check(12));
        System.out.println(((Son2) person2).get());
        System.out.println(person2.check(2));
    }

}

class Person{
    public Integer temp = 0;

    public Boolean check(Integer temp2){
        if (temp.intValue() == temp2) {
            return true;
        }
        return false;
    }
}

class Son extends Person{

    public Son(){
        super.temp = 1;
    }

    public Integer get(){
        return super.temp;
    }
}
class Son2 extends Person{

    public Son2(){
        super.temp = 2;
    }

    public Integer get(){
        return super.temp;
    }
}